﻿//Zaokrąglenie
function Round(n, k) {
    var factor = Math.pow(10, k);
    return Math.round(n * factor) / factor;
}

function Units(number) {

    //Terebajty
    if (number > 1000000000) {
        return Round( (number / 1000000000) , 2) + ' TB';
    }
    //Gigabajty
    else if (number > 1000000) {
        return Round((number / 1000000), 2) + ' GB';
    }
    //Megabajty
    else if (number > 1000) {
        return Round((number / 1000), 2) + ' MB';
    }
    //Kilobajty
    else {
        return Round(number, 2) + ' KB';
    }
}